<?php
	$data['logged'] = false;
	
	// If login pressed
	if($this->input->post("loginButton"))
	{
		// Gather input
		$username = $this->input->post("username");
		$password = $this->input->post("password");
		
		if($username != null && $password != null)
		{
			// Do login
			$this->login_model->DoLogin($username, $password);
			echo "<meta http-equiv='refresh' content='0'>";
		}
	}
	
	// If logout pressed, destroy & logout and refresh page
	if($this->input->post("logoutButton"))
	{
		$this->login_model->DoLogout();
		echo "<meta http-equiv='refresh' content='0'>";
	}
	
	// Handle status depending on logged/or not
	// Display the correct view depending on login-status
	if($this->login_model->IsLoggedIn())
	{
		$data['logged'] = true;
		$data['user'] = $this->login_model->GetUser();
	}
	$this->load->view("login/loginStatus",$data);